#ifndef __GATEWAYSERVERRECIEVER_H__
#define __GATEWAYSERVERRECIEVER_H__

#include "gwmessagetab.hpp"
#include "IMessageOperator.h"
#include "protonet.hpp"
#include "../NetMessageTab.h"
#include "gatewayserver.pb.h"
#include "../GatewayServer/GatewayServerTab.h"

/**
*@file       GatewayServerReciever.h
*@brief      process message GatewayServer
*
*@author     graywind
*@version    1.0.0.0
*@data       2012/3/16
*/

///process message
class OnGatewayServer
{
public:
    ///@brief    process message
    ///param[in] op            operator type
    ///param[in] session_id    identifier of session
    ///param[in] pMsgBuffer    message buffer
    ///param[in] msg_bytes     byte length of message buffer
    ///retval    void
    static void OnMapping(IMessageOperator* op, int session_id, void* pMsgBuffer, unsigned long msg_bytes)
    {
        //TODO
        GatewayServerMain mainMsg;
        if(ProtoNet<GatewayServerMain>::CreateFromBytes(mainMsg, pMsgBuffer, msg_bytes))
        {
            GatewayServerProcessor::ProcessMessage(op, session_id, (void*)mainMsg.subbuffer().c_str(), mainMsg.subid(), mainMsg.subbuffer().length() > 0 ? mainMsg.subbuffer().length() : 0);
        }
    }
};

///[message group]  [message type]  [function table] [handler]
RegisterMessageTab(NetMessageTypes, GatewayServer, NetMessageTab, OnGatewayServer);
#endif
